<?php
require('includes/connect.php');

	$quest = $_POST['quest'];
	$name = $_POST['fname']." ".$_POST['lname'];
	$email = $_POST['email'];
	$company_name = $_POST['company_name'];
	$tele_no = $_POST['tel_code']."-".$_POST['phone'];
	$mob_no = $_POST['mob_code']."-".$_POST['mob'];
		
	$path = "files/";
	$path = $path . basename( $_FILES['upload_query']['name']); 
	if(move_uploaded_file($_FILES['upload_query']['tmp_name'], $path))
	{

	$insert_search_quest = mysql_query("insert into question_asked (`name`, `email`, `comp_name`, `tel`, `mob`, `upload_file`) values ('$name', '$email', '$company_name', '$tele_no', '$mob_no', '$path')");

		 if($insert_search_quest)
		 {
			echo '<div style="text-align:left;">';
			echo '<ul type="square">';
			$question=$_POST['id'];
			$qu=mysql_query("select * from faq where faq like '%$question%'");
			while($row=mysql_fetch_array($qu))
			{
				echo '<li><b>'.$row['faq'].'</b>';
			$faq_id=$row['faq_id'];
				$ans=mysql_query("select * from answers where faq_id=".$faq_id);
				echo '<ul>';
				$i="1";
				while($res=mysql_fetch_array($ans))
				{
					echo '<li>Ans&nbsp;'.$i.'&nbsp; - '.$res['answers'].'</li>';
					$i++;
				}
				echo '</ul></li>';
			}
			echo '</ul>';
		 }
		 else
		 {
			 echo mysql_error();
		 }
	}
?>
